window.$config = {
    // host: location.hostname=='h5.oeeee.com'?'/index.php':'/mmp_bak/htdocs/uncache.php',
    host: '/index.php',
    rex:{
        tel : /^1[34578]\d{9}$/
    },
    urlCode: function (obj) {
        var str = [];
        for (var p in obj) {
            str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
        }
        return str.join("&");
    },
    // 滚动到顶部
    toTop: function (func) {
        var timer = setInterval(function(){
            //获取滚动条距离顶部高度
            var osTop = document.documentElement.scrollTop || document.body.scrollTop;
            var ispeed = Math.floor(-osTop / 7);

            document.documentElement.scrollTop = document.body.scrollTop = osTop+ispeed;
            //到达顶部，清除定时器
            if (osTop == 0) {
                clearInterval(timer);
                if(func){
                    func();
                }
            };
        },30);
    },
    iswx : function(){
        var ua = window.navigator.userAgent.toLowerCase();
        if(ua.match(/MicroMessenger/i) == 'micromessenger'){
            return true;
        }else{
            return false;
        }
    },
    wxShare : function(Option) {
        if(!this.iswx()) return;
        var time = setInterval(function () {
            try {
                if (!wx || !oe_wxconfig) return;
            } catch (e) {
            }

            clearTimeout(time);
            //初始化
            if(!Option) Option={};
            var config = oe_wxconfig,
                title = Option.title ? Option.title : "这些隐私政策“靠谱”么？",
                summary = Option.cont ? Option.cont : "互联网企业隐私政策透明度测评",
                link = Option.url ? Option.url : "http://h5.oeeee.com/h5/v17/evaluation",
                thumb = "http://h5.oeeee.com/h5/v17/evaluation/logo.jpg",
                content = {
                    title: title,
                    desc: summary,
                    link: link,
                    imgUrl: thumb,
                    type: '',
                    dataUrl: '',
                    success: function () {
                    },
                    cancel: function () {
                    }
                }

            wx.config({
                debug: false,
                appId: config.appId,
                timestamp: config.timestamp,
                nonceStr: config.nonceStr,
                signature: config.signature,
                jsApiList: [
                    'onMenuShareAppMessage', 'onMenuShareTimeline', 'onMenuShareQQ', 'onMenuShareWeibo'
                ]
            });
            wx.checkJsApi({
                jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline', 'onMenuShareQQ', 'onMenuShareWeibo'],
                success: function (res) {
                }
            });
            wx.ready(function () {
                wx.onMenuShareAppMessage(content);
                wx.onMenuShareTimeline(content);
                wx.onMenuShareQQ(content);
                wx.onMenuShareWeibo(content);
            });
        },500);
    },
    init : function () {
        if(this.iswx()){
            var jwx1 = document.createElement('script');
            jwx1.setAttribute('src','http://res.wx.qq.com/open/js/jweixin-1.0.0.js');
            document.body.appendChild(jwx1);
            var jwx2 = document.createElement('script');
            jwx2.setAttribute('src','https://m.mp.oeeee.com/helper.php?m=WxHelper&a=config&domain=oeeee.com');
            document.body.appendChild(jwx2);
        }
    }
}

$config.init();